package com.idp.app.controller;

import com.idp.app.dto.*;
import com.idp.app.service.SyAjxxService;
import com.idp.app.service.SyLxrService;
import com.idp.common.base.BaseController;
import com.idp.common.model.ResultModel;
import com.idp.common.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大屏服务
 *
 * @author Simon
 */
@Api(tags = "大屏服务-首页")
@RestController
@RequestMapping("/screen/")
public class ScreenController extends BaseController {

    @Autowired
    private SyAjxxService syAjxxService;
    @Autowired
    private SyLxrService syLxrService;

    /**
     * 首页-类别分布
     *
     * @return
     */
    @ApiOperation(value = "首页-类别分布-没有入参，数据不随地图更改而改变")
    @PostMapping("getAllLxNum")
    public ResultModel<List<SyAjxxLxDto>> getAllLxNum(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syAjxxService.getAllLxNum(screenCommonDto));
    }


    /**
     * 首页-空间分布
     *
     * @return
     */
    @ApiOperation(value = "首页-空间分布-没有入参，数据不随地图更改而改变")
    @PostMapping("getKjfb")
    public ResultModel<List<com.idp.system.dto.SyAjxxKjfbDto>> getKjfb(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syAjxxService.getKjfb(screenCommonDto));
    }

    /**
     * 大屏-中间上边部分数据
     *
     * @return
     */
    @ApiOperation(value = "首页-中间上边部分数据-数据总量|时间跨度|区域范围|数据类别-入参为空")
    @PostMapping("getSjzlSjkd")
    public ResultModel<SyAjxxSjfwDto> getSjzlSjkd(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syAjxxService.getSjzlSjkd(screenCommonDto));
    }

    /**
     * 大屏-基层治理检查指数
     *
     * @return
     */
    @ApiOperation(value = "首页-基层治理检查指数-入参：地区编码")
    @PostMapping("getJczljczs")
    public ResultModel<SyAjxxJczljczsDto> getJczljczs(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syAjxxService.getJczljczs(screenCommonDto));
    }

    /**
     * 地图中间部分-根据地区查询案件数量
     *
     * @return
     */
    @ApiOperation(value = "首页-地图中间部分-根据地区查询案件数量-入参：地区编码")
    @PostMapping("getAjxxxx")
    public ResultModel<SyAjxxAjslDto> getAjxxxx(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syAjxxService.getAjxxxx(screenCommonDto));
    }


    /**
     * 首页-镇街检查联络表-右下角-入参：地区编码
     *
     * @param screenCommonDto
     * @return
     */
    @ApiOperation(value = "首页-镇街检查联络表-右下角-入参：地区编码，后端用bz匹配地区编码，新增时将bz赋值地区编码")
    @PostMapping("getSyLxrByDqbm")
    public ResultModel<List<SyLxrDto>> getSyLxrByDqbm(@RequestBody ScreenCommonDto screenCommonDto) {
        return ResultModel.success(syLxrService.getSyLxrByDqbm(screenCommonDto));
    }


    /**
     * 首页-生成报告
     *
     * @param screenParamDto
     * @return
     */
    @ApiOperation(value = "首页-生成报告")
    @PostMapping("getReport")
    public ResultModel<List<ReportDto>> getReport(@RequestBody ScreenParamDto screenParamDto) {
        String startDate = screenParamDto.getStartDate();
        String endDate = screenParamDto.getEndDate();
        String currentStartDateFormat = DateUtils.getCurrentDateFormat1(startDate);
        String currentEndDateFormat = DateUtils.getCurrentDateFormat1(endDate);
        screenParamDto.setSDate(currentStartDateFormat);
        screenParamDto.setEDate(currentEndDateFormat);
        return ResultModel.success(syAjxxService.getReport(screenParamDto));
    }

}
